package com.status.mapper;

import com.status.pojo.UserDo;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.List;

public class UserDao extends SqlSessionDaoSupport {

    /**
     * 查询用户数据
     * @return
     */
    public List<UserDo> selectUser() {
        return getSqlSession().getMapper(UserMapper.class).selectUser();
    }
    //增加
    public int addUser(UserDo user){
        return getSqlSession().getMapper(UserMapper.class).addUser(user);
    }
    //删除
    public int delUser(int id){
        return getSqlSession().getMapper(UserMapper.class).delUser(id);
    }
    //事务验证
    public void txAdvice(){
        UserDo userDo = new UserDo();
        userDo.setId(1991);
        userDo.setName("1991");
        userDo.setPwd("1991");
        addUser(userDo);
        int a = 1/0;
        delUser(1991);
    }
}
